package version.test.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import version.test.dao.WeaponMapper;
import version.test.dto.entity.WeaponEntity;
import version.test.service.impl.es.WeaponESService;

/**
 * @description:
 * @author: hzw
 * @time: 2023/11/10 17:47
 */
@Service
public class WeaponServiceImpl {
    @Autowired
    private WeaponMapper weaponMapper;
    @Autowired
    private WeaponESService weaponESService;

    public void save(WeaponEntity weaponEntity) {
        weaponMapper.insert(weaponEntity);
        weaponESService.save(weaponEntity);
    }

    public Page<WeaponEntity> selectByName(String name) {
        QueryWrapper<WeaponEntity> wrapper = new QueryWrapper<>();
        wrapper.select("id", "code", "name").lambda().like(WeaponEntity::getName, name);
        return weaponMapper.selectPage(new Page<>(1, 10, 10), wrapper);
    }
}
